home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Format CD 46
/
Amiga Format CD46 (1999-10-20)(Future Publishing)(GB)[!][issue 1999-12].iso
/
-in_the_mag-
/
reader_requests
/
scilab
/
tests
/
lstops.tst
< prev
next >
Wrap
Text File
|
1999-09-16
|
3KB
|
99 lines
mode(5)
//-----------------------
//-- extractions tests --
//-----------------------
l=list(1,2,-4);
if l(1)<>1 then pause,end
if l(3)<>-4 then pause,end
[x1,x2]=l([1 3]);
if x1<>l(1)|x2<>l(3) then pause,end
[x2,x1]=l([3 1]);
if x1<>l(1)|x2<>l(3) then pause,end
[x1,x2]=l([1;3]);
if x1<>l(1)|x2<>l(3) then pause,end
[x2,x1]=l([3;1]);
if x1<>l(1)|x2<>l(3) then pause,end
[x1,x2,x3]=l(:);
if x1<>l(1)|x2<>l(2)|x3<>l(3) then pause,end
//with full tlists
l=tlist(['t','a','b','c'],1,-2,5);
if l(2)<>1 then pause,end
if l(4)<>5 then pause,end
[x1,x2]=l([2 4]);
if x1<>l(2)|x2<>l(4) then pause,end
[x2,x1]=l([4 2]);
if x1<>l(2)|x2<>l(4) then pause,end
if l('a')<>1 then pause,end
if l('c')<>5 then pause,end
[x1,x2]=l(['a' 'c']);
if x1<>l('a')|x2<>l('c') then pause,end
[x2,x1]=l(['c' 'a']);
if x1<>l('a')|x2<>l('c') then pause,end
[x1,x2]=l(['a';'c']);
if x1<>l('a')|x2<>l('c') then pause,end
[x2,x1]=l(['c';'a']);
if x1<>l('a')|x2<>l('c') then pause,end
//with partial tlists (no elements formal names)
l=tlist('t',1,-2,5);
deff('[f1,f2,f3,f4,f5,f6,f7]=%te(i,j,f)',[
'nams=[''a'',''b'',''c''];'
'for k=1:prod(size(i))';
' kf=find(i(k)==nams);';
' if kf==[] then error(21),end;'
' execstr(''f''+string(k)+''=j(kf+1)'');'
' end;'])
if l(2)<>1 then pause,end
if l(4)<>5 then pause,end
[x1,x2]=l([2 4]);
if x1<>l(2)|x2<>l(4) then pause,end
[x2,x1]=l([4 2]);
if x1<>l(2)|x2<>l(4) then pause,end
if l('a')<>1 then pause,end
if l('c')<>5 then pause,end
[x1,x2]=l(['a' 'c']);
if x1<>l('a')|x2<>l('c') then pause,end
[x2,x1]=l(['c' 'a']);
if x1<>l('a')|x2<>l('c') then pause,end
[x1,x2]=l(['a';'c']);
if x1<>l('a')|x2<>l('c') then pause,end
[x2,x1]=l(['c';'a']);
if x1<>l('a')|x2<>l('c') then pause,end
//---------------------
//-- insertion tests --
//---------------------
l=list(2,'a',-1);
l(1)=[1 2];
if l<>list([1 2],'a',-1) then pause,end
l(1)=33;
if l<>list(33,'a',-1) then pause,end
l(1)=33;
if l<>list(33,'a',-1) then pause,end
l(0)=1.25;
if l<>list(1.25,33,'a',-1) then pause,end
l(5)=[1 2 3];
if l<>list(1.25,33,'a',-1,[1 2 3]) then pause,end
l(3)=null();
if l<>list(1.25,33,-1,[1 2 3]) then pause,end
l(3)=null();
if l<>list(1.25,33,[1 2 3]) then pause,end
l(4)=null();
if l<>list(1.25,33,[1 2 3]) then pause,end
l(0)=null();
if l<>list(1.25,33,[1 2 3]) then pause,end
l=tlist('t',2,'a',-1);
l(2)=[1 2 3];
if %lnl(l,tlist('t',[1 2 3],'a',-1)) then pause,end
l(2)=33;
if %lnl(l,tlist('t',33,'a',-1)) then pause,end
l(2)=33;
if %lnl(l,tlist('t',33,'a',-1)) then pause,end
l(4)=[1 2];
if %lnl(l,tlist('t',33,'a',[1,2])) then pause,end
l(2)=null();
if %lnl(l,tlist('t','a',[1,2])) then pause,end
l(1)=null();
if %lnl(l,list('a',[1,2])) then pause,end